<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 原型链继承,继承的是方法:  子类.原型=new  父类方法()
    // 遍历父类所有原型方法赋值给子类原型方法

    function add(day, time) {
      this.day = day;
      this.time = time;
    }

    add.prototype.tday = function () {
      console.log(this.day);
    };
    add.prototype.sum = function () {
      console.log(this.sum);
    };

    //子类
    function home(day, time, tree) {
      add.call(this, day, time); // 修改this指向
      this.tree = tree;
    }

    //1. 子类.原型=new  父类方法()
    home.prototype = new add();//继承方法

    thod.prototype.why = function () {
      console.log(this.tree);
    };

    //遍历父类所有原型方法赋值给子类原型方法
    // for(var i in User.prototype){
    //   // console.log('父类原型方法',User.prototype);
    //   VipUser.prototype[i]=User.prototype[i]
    // }

    var dhu = new thod("11", "22", 3);

    dhu.tday();
    dhu.sum(); //函数
    dhu.why();
  </script>
</html>
